package spring.main;

import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;

import spring.bean.Company;
import spring.bean.Employee;

public class BeanWrapUse {
	public static void main(String[] args) {
		//setting the company name..
		BeanWrapper company=new BeanWrapperImpl(new Company());
		company.setPropertyValue("name", "some company inc.");
		//can also be done like this:
//		PropertyValue value=new PropertyValue("name", "some company inc.");
//		company.setPropertyValue(value);
		
		//ok,let's create the employee
		BeanWrapper john=new BeanWrapperImpl(new Employee());
		john.setPropertyValue("name", "john");
		john.setPropertyValue("salary", "10000");
		
		company.setPropertyValue("employee", john.getWrappedInstance());
		
		String salaryString=(String) company.getPropertyValue("employee.salary");
		System.out.println(salaryString);
	}
}
